# config.py
import logging
import os


class Config:
    DEBUG = True
    HOST = "0.0.0.0"
    PORT = 5001
    CORS_ORIGINS = ["*"]
    SQLALCHEMY_DATABASE_URI = (
        "mysql+mysqlconnector://mytool:rimBHTaFa57eaRKZ@8.136.71.236:3306/mytool"
    )
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    LOG_FILE = os.path.join("logs", "app.log")
    LOG_LEVEL = logging.INFO  # 默认日志级别


class DevelopmentConfig(Config):
    DEBUG = True
    LOG_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    DEBUG = False
    LOG_LEVEL = logging.WARNING
    # CORS_ORIGINS = ["https://yourcompany.com"]  # 去除尾部空格


def get_config():
    env = os.environ.get("FLASK_ENV", "development")
    if env == "production":
        return ProductionConfig()
    return DevelopmentConfig()


# 默认导出当前环境配置
config = get_config()
